iOS image button setCornerRadius
iOS image button setCornerRadius
当我们在button上添加背景图片和背景颜色的时候就会发现,setCornerRadius这个属性并不适用,因为现在的button已经不是圆角的了,它显示的是图片的形状,当设置背景颜色设置为UIButtonTypeCustom属性才可以显示出来。所以我们需要用UIButton控件的其它属性来满足我们的需求
\
[self.headerBtn setImage:[UIImage imageNamed: “mine_000”] forState:UIControlStateNormal];
[self.headerBtn.layer setMasksToBounds:YES];
[self.headerBtn.layer setCornerRadius:40.0f];//圆角
\
\
\
\
Use this for
convert UIImage
{style=” padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, ‘Lucida Console’, ‘Liberation Mono’, ‘DejaVu Sans Mono’, ‘Bitstream Vera Sans Mono’, ‘Courier New’, monospace, sans-serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);”} to NSData
{style=” padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, ‘Lucida Console’, ‘Liberation Mono’, ‘DejaVu Sans Mono’, ‘Bitstream Vera Sans Mono’, ‘Courier New’, monospace, sans-serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);”}.
NSData*imagedata =UIImagePNGRepresentation(thumbnail);
Try this for image data convert back
to UIImage
{style=” padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, ‘Lucida Console’, ‘Liberation Mono’, ‘DejaVu Sans Mono’, ‘Bitstream Vera Sans Mono’, ‘Courier New’, monospace, sans-serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);”}
UIImage *image= [UIImage imageWithData:imagedata];
{style=”padding: 0px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, ‘Lucida Console’, ‘Liberation Mono’, ‘DejaVu Sans Mono’, ‘Bitstream Vera Sans Mono’, ‘Courier New’, monospace, sans-serif; background-color: rgb(238, 238, 238);”}